<?php
/**
 * Javascript class
 * 
 * @author Mathieu Pheulpin - sokaru91@gmail.com
 *
 */
class Mac_Javascript
{
    public static function googleAnalytics ($code)
    {
        $js = '<script type="text/javascript">';
            $js .= 'var _gaq = _gaq || [];';
            $js .= '_gaq.push([\'_setAccount\', \''.$code.'\']);';
            $js .= '_gaq.push([\'_trackPageview\']);';
            $js .= '(function() {';
                $js .= 'var ga = document.createElement(\'script\'); ga.type = \'text/javascript\'; ga.async = true;';
                $js .= 'ga.src = (\'https:\' == document.location.protocol ? \'https://ssl\' : \'http://www\') + \'.google-analytics.com/ga.js\';';
                $js .= 'var s = document.getElementsByTagName(\'script\')[0]; s.parentNode.insertBefore(ga, s);';
            $js .= '})();';
        $js .= '</script>';
        return $js;
    }
    
    public static function jQuery ($version = '1.6.4')
    {
        return '<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/'.$version.'/jquery.min.js"></script>';
    }
    
    public static function swfObject ($version = '2.2')
    {
        return '<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/swfobject/'.$version.'/swfobject.js"></script>';
    }
    
    public static function localFile ($path)
    {
        return '<script type="text/javascript" src="/js/'.$path.'"></script>';
    }
}